#include "ALarret.h"
#include "Robot.h" 

/**
 * avance le robot
 */
void ALarret::avancer()
{
	int x=0;
	int y=0;
	std::string dir = robot->direction().getDirection();
	if(dir=="sud"){
		x=-1;
	}
	else if(dir=="ouest"){
		y=-1;
	}
	else if(dir=="nord"){
		x=1;
	}
	else {
		y=1;
	}
	std::cout << "Avance de ("<< x << "," << y << ")" << std::endl;
	robot->position().addX(x);
	robot->position().addY(y);
	std::cout << "Nouvelle position : x="<< robot->position().getX() << " y=" << robot->position().getY()  << std::endl;
}

/**
 * tourne le robot
 */
void ALarret::tourner()
{
	std::string newDir;
	std::string dir = robot->direction().getDirection();
	if(dir=="sud"){
		newDir="est";
	}
	else if(dir=="ouest"){
		newDir="sud";
	}
	else if(dir=="nord"){
		newDir="ouest";
	}
	else{
		newDir="nord";
	}
	robot->direction().setDirection(newDir);
	std::cout << "Tourne vers " << robot->direction().getDirection() << std::endl;
}
